package com.jisf.driver.controller;

import com.jisf.driver.entity.po.ApplicationPackage;
import com.jisf.driver.response.Result;
import com.jisf.driver.response.ResultCode;
import com.jisf.driver.service.IApplicationPackageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jisf
 * @since 2022-05-12
 */
@RestController
@RequestMapping("/driver/applicationPackage")
public class ApplicationPackageController {

    @Autowired
    private IApplicationPackageService iApplicationPackageService;

    @GetMapping("getApplyList")
    @PreAuthorize("hasAnyAuthority('applicationPackage:getApplyList')")
    public Result<?> getApplyList(){
        List<ApplicationPackage> applyList = iApplicationPackageService.getApplyList();
        return Result.ok(applyList);
    }

    @GetMapping("deleteApply")
    @PreAuthorize("hasAnyAuthority('applicationPackage:deleteApply')")
    public Result<?> deleteApply(@RequestParam Integer id){
        ResultCode resultCode = iApplicationPackageService.deleteApply(id);
        return Result.ok(resultCode);
    }

    @PostMapping("addApply")
    @PreAuthorize("hasAnyAuthority('applicationPackage:addApply')")
    public Result<?> addApply(@RequestBody ApplicationPackage applicationPackage){
        ResultCode resultCode = iApplicationPackageService.addApply(applicationPackage);
        return Result.ok(resultCode);
    }
}
